from numpy import arange, sin, pi
import matplotlib
from scipy.io import wavfile
matplotlib.use('WXAgg')

from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
from matplotlib.backends.backend_wx import NavigationToolbar2Wx
from matplotlib.figure import Figure

import wx

class CanvasPanel(wx.Panel):
    def __init__(self, parent):
	wx.Panel.__init__(self, parent)
	self.figure = Figure()
	self.axes = self.figure.add_subplot(111)
	self.figure2 = Figure()
	self.axes2 = self.figure.add_subplot(111)
	self.canvas2 = FigureCanvas(self, -1, self.figure2)
        self.canvas = FigureCanvas(self, -1, self.figure)
        self.sizer = wx.BoxSizer(wx.VERTICAL)
        self.sizer1 = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer2 = wx.BoxSizer(wx.HORIZONTAL)
        self.sizer1.Add(self.canvas, 1, wx.LEFT | wx.TOP | wx.GROW)
	self.sizer2.Add(self.canvas2, 1, wx.LEFT | wx.BOTTOM | wx.GROW)
        self.SetSizer(self.sizer)
        self.Fit()

    def draw(self):
	audio = wavfile.read('discovery.wav')
	audio2 = wavfile.read('disconnect_me.wav')
        #t = arange(0.0, 3.0, 0.01)
        #s = sin(2 * pi * t)
	self.axes.plot(audio[1])
	self.axes2.plot(audio2[1])


if __name__ == "__main__":
    app = wx.PySimpleApp()
    fr = wx.Frame(None, title='test')
    panel = CanvasPanel(fr)
    panel.draw()
    fr.Show()
    app.MainLoop()
